package com.smartparking.common;

/**
 * @author ganru
 * @date 2025/11/3 11:22
 */
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Response<T> {

    // 响应状态码
    private int statusCode;

    // 响应信息
    private String message;

    // 响应数据
    private T data;

    // 成功的响应
    public static <T> Response<T> success(T data) {
        return new Response<>(200, "操作成功", data);
    }

    public static <T> Response<T> successMessage(String message) {
        return new Response<>(200, message, null);
    }

    // 错误的响应
    public static <T> Response<T> error(int statusCode, String message) {
        return new Response<>(statusCode, message, null);
    }

    public static <T> Response<T> errorMessage(String message) {
        return new Response<>(500, message, null);
    }
}
